<template>
  <div>
    <h3>添加商品</h3>
    <p>商品名称: <input type="text" name="" id="" v-model="gname"></p>
    <p>商品价格: <input type="text" name="" id="" v-model.number="price"></p>
    <!-- <p><button @click="addGoods({gname,price})">添加</button></p> -->
    <p><button @click="addGoods({gname,price})">添加</button></p>
  </div>
</template>

<script>
// import {mapActions} from 'vuex'
export default {
    name:'AddGoods',
    data(){
        return {
            gname:'',
            price:undefined
        }
    },
    methods:{
        // ...mapActions('goods', ['addGoods'])
        addGoods(){
            this.$store.dispatch('goods/addGoods', {gname:this.gname, price:this.price})
            this.gname = ''
            this.price = undefined
        }
    }
}
</script>

<style>

</style>